package com.xingshang.util;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FileStorageUtilFactory {

    @Value("${storage.type}")
    private String storageType;

    private final MinioUtil minioUtil;
    private final AliOssUtil ossUtil;

    public FileStorageUtil getStorageUtil() {
        if ("minio".equalsIgnoreCase(storageType)) {
            return minioUtil;
        } else if ("oss".equalsIgnoreCase(storageType)) {
            return ossUtil;
        }
        throw new RuntimeException("不支持的存储类型: " + storageType);
    }
}
